package com.jiangruan.javaproject.utils;

import com.jiangruan.javaproject.address.BitCoinAddress;
import com.jiangruan.javaproject.bean.HotVideo;
import com.jiangruan.javaproject.bean.HotVideoCommon;
import com.jiangruan.javaproject.service.GetBestBlockHashService;
import com.jiangruan.javaproject.service.HotVideoService;

import java.util.List;
import java.util.Scanner;

/**
 * @author:liuzuoqiang
 * @email:2639571477@qq.com
 * @desc:  该类是java项目的主函数的类，是程序的入口
 * @datetime: 2021/12/30 22:34
 */

public class Main {
    public static void main (String[] args) {
        new Main().run();
    }

    public void run(){
        System.out.println("=======java期末考查大作业系统=========");
        System.out.println("该系统已实现如下功能：");
        while (true){
            menu();
        }
    }

    public void menu(){
        System.out.println("1.聚合数据 2. 比特币客户端通信 3. 地址生成 4.地址校验 0.退出");
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        switch (num){
            case 1:
                HotVideoService hotVideoService = new HotVideoService();
                List<HotVideo> hotVideo = hotVideoService.getHotVideo();
                for (int i = 0; i < hotVideo.size(); i++){
                    System.out.println(hotVideo.get(i).toString());
                }

                break;
            case 2:
                String bestBlockHash = new GetBestBlockHashService().getBestBlockHash();
                System.out.println(bestBlockHash);
                break;
            case 3:
                BitCoinAddress address = new BitCoinAddress();
                String address1 = address.newAddress();
                System.out.println(address1);

                break;
            case 4:
                System.out.println("输入需校验的地址：");
                Scanner scanner2 = new Scanner(System.in);
               String a = scanner2.next();
                BitCoinAddress address2 = new BitCoinAddress();

                boolean b = address2.validateAddress(a);
                System.out.println(b);

                break;
            case 0:
                System.exit(0);
                break;
            default:
                System.out.println("暂不支持的功能");
        }
    }
}

